package cn.tang.tframe.storage.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 文件处理工具类
 * 
 * @author wpliu
 * 
 */
public class FileDealUtil {
	public static final String ALL_CHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

	public static String fileRename() {
		StringBuffer sb = new StringBuffer();
		Random random = new Random();
		for (int i = 0; i < 10; i++) {
			sb.append(ALL_CHAR.charAt(random.nextInt(ALL_CHAR.length())));
		}
		return nowStr() + "." + sb.toString();
	}


    public static String nowStr() {
        String str = null;
        DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");

        Date date = new Date(System.currentTimeMillis());
        str = format.format(date);

        return str;
    }
    public static String nowHour() {
        String str = null;
        DateFormat format = new SimpleDateFormat("yyyyMMddHH");

        Date date = new Date(System.currentTimeMillis());
        str = format.format(date);

        return str;
    }

    public static void main(String[] args) {
		System.out.print(FileDealUtil.fileRename());
	}
}
